import java.util.Arrays;

public class Leetcode1827 {
    public int minOperations(int[] nums) {
        if (nums.length == 1) {
            return 0;
        }

        int res = 0;
        for (int i = 1; i < nums.length; i++) {
            if (nums[i] > nums[i - 1]) {
                continue;
            }

            res += nums[i - 1] - nums[i] + 1;
            nums[i] = nums[i - 1] + 1;
        }

        return res;
    }

}

